CC = gcc
LD = gcc
CFLAGS = -Wall -c -I./include

DIR = ./
DIR_LIB = $(DIR)/lib
DIR_SRC = $(DIR)/src

SRCS_LIB_CMN = $(wildcard $(DIR_LIB)/cmn/*.c)
OBJS_LIB_CMN = $(patsubst %c,%o,$(SRCS_LIB_CMN))
SRCS_LIB_MOD = $(wildcard $(DIR_LIB)/module/*.c)
OBJS_LIB_MOD = $(patsubst %c,%o,$(SRCS_LIB_MOD))
SRCS_LIB_DICT = $(wildcard $(DIR_LIB)/dictionary/*.c)
OBJS_LIB_DICT = $(patsubst %c,%o,$(SRCS_LIB_DICT))
SRCS_CORE = $(wildcard $(DIR_SRC)/*.c)
OBJS_CORE = $(patsubst %c,%o,$(SRCS_CORE))
OBJ_ALL = $(OBJS_LIB_CMN) $(OBJS_LIB_DICT) $(OBJS_LIB_MOD) $(OBJS_CORE)
TARGET = apple.exe

.PHONY: all clean

all: $(TARGET)

$(TARGET): $(OBJS_LIB_CMN) $(OBJS_LIB_DICT) $(OBJS_LIB_MOD) $(OBJS_CORE)
	$(LD) $(LDFLAGS) -o $@ $^

%o: %c
	$(CC) $(CFLAGS) -o $@ $<
clean:
	rm -f *.o $(TARGET)

